﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Threading;
using System.Collections;
using System.Data.SqlClient;
public partial class Controls_pie : System.Web.UI.UserControl
{
        protected void Page_Load(object sender, EventArgs e)
    {
        
        Chart1.Titles.Add("各学科资源分布圆饼图");
        DBaccess db = new DBaccess();
        DataSet ds = new DataSet();
        ds = db.GetDataSet("select * from mr_v_pie");
        SqlDataReader read = db.GetReader("select count(*) from mr_v_pie");
        read.Read();
        int num = int.Parse(read.GetValue(0).ToString());
        string[] xValue=new string[num];
        double[] yValue=new double[num];
        //Chart1.BorderSkin.SkinStyle = FrameTitle4;    //设置图表边框为浮雕效果
        //Chart1.BorderlineDashStyle = ChartDashStyle.Solid;    //设置图表边框为实线
        Chart1.BorderlineWidth = 1;    //设置图表边框的宽度

        //Chart1.Series[0].ChartType = SeriesChartType.Pie;    //设置图表类型为饼图
        Chart1.Series["Series1"].CustomProperties = "DoughnutRadius=25, PieDrawingStyle=Concave, CollectedLabel=Other, MinimumRelative" + "PieSize=20";    //设置饼图的参数
        Chart1.Series["Series1"].Label = "#PERCENT{P}";

        
        for (int i = 0; i < num; i++)
        {
               //设置标签
            xValue[i] = ds.Tables[0].Rows[i][0].ToString();
            
            yValue[i] = double.Parse(ds.Tables[0].Rows[i][1].ToString());
            
        }//将数据绑定到图表
        Chart1.Series["Series1"].AxisLabel = "#VALX";
        Chart1.Series["Series1"].Points.DataBind(ds.Tables[0].AsDataView(), "dname", "countnum", "LegendText=dname,YValues=countnum,ToolTip=countnum"); //绑定数据
        Chart1.Series["Series1"].ToolTip = "#LEGENDTEXT: #VAL{C} million"; //鼠标悬浮显示信息
        Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false; //3D模式
        //Chart1.Series["Series1"].Points.DataBindXY(xValue, yValue);
    }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("../Management/PieGraph.aspx");
        }
}